import { type InputProps, type SelectProps } from '@arco-design/web-react';
import { ColumnProps, TableProps } from '@arco-design/web-react/es/Table';

// search form
export type SearchFormItemType = 'Input' | 'Custom' | 'Select';

export interface SearchFormInputProps extends InputProps {
  colSpan?: number;
  fieldName: string;
  placeholder?: string;
  label: string;
  type: 'Input';
}

export interface SearchSelectProps extends SelectProps {
  colSpan?: number;
  fieldName: string;
  placeholder?: string;
  label: string;
  type: 'Select';
}

export interface CustomFormItemProps {
  colSpan?: number;
  fieldName: string;
  label: string;
  type: 'Custom';
  placeholder?: string;
  defaultValue?: string;
  component: JSX.Element;
}

export type FormOptions =
  | SearchSelectProps
  | SearchFormInputProps
  | CustomFormItemProps;

// table
export interface ITableProps
  extends Omit<TableProps, 'data' | 'loading' | 'rowKey' | 'pagination'> {
  rowKey?: string;
}

export interface IPaginationProps {
  showTotal?: boolean;
  totalField?: string;
  pageField?: string;
  pageSizeField?: string;
}

export interface ProTableProps {
  columns: ColumnProps<any>[];
  defaultQueryData?: Record<string, any>;
  children?: React.ReactNode;
  operation?: React.ReactNode;
  showSearchForm?: boolean;
  pagination?: IPaginationProps;
  showPagination?: boolean;
  formOptions?: FormOptions[];
  showCreatedTime?: boolean;
  createdTimeText?: string;
  tableProps?: ITableProps;
  emptyText?: string;
  queryKey: string | symbol;
  queryFn: (params?: any) => Promise<any>;
  tableRowKey?: string | number;
}
